﻿#ifndef Q_STYLE_H
#define Q_STYLE_H

#include "QCore.h"


enum
{
    STYLE_BG_COLOR, //背景颜色
    STYLE_FG_COLOR, //前景颜色
    STYLE_MASK_COLOR, //蒙版颜色
    STYLE_FONT_NAME, //字体名称
    STYLE_FONT_SIZE, //字体大小
    STYLE_FONT_STYLE, //字体风格
    STYLE_TEXT_COLOR, //STYLE_TEXT_COLOR
    STYLE_HIGHLIGHT_FONT_NAME, //高亮文本的字体名称
    STYLE_HIGHLIGHT_FONT_SIZE, //高亮文本的字体大小
    STYLE_HIGHLIGHT_TEXT_COLOR, //高亮文本的文本颜色
    STYLE_TIPS_TEXT_COLOR, //提示文本颜色
    STYLE_TEXT_ALIGN_H, //文本水平对齐的方式
    STYLE_TEXT_ALIGN_V, //文本垂直对齐的方式
    STYLE_BORDER_COLOR, //边框颜色
    STYLE_BORDER_WIDTH, //边框线宽
    STYLE_BORDER, //边框类型
    STYLE_BG_IMAGE, //图片的名称
    STYLE_BG_IMAGE_DRAW_TYPE, //图片的显示方式
    STYLE_ICON, //图标的名称
    STYLE_FG_IMAGE, //图片的名称
    STYLE_FG_IMAGE_DRAW_TYPE, //图片的显示方式
    STYLE_SPACER, //间距
    STYLE_MARGIN, //边距
    STYLE_MARGIN_LEFT, //左边距
    STYLE_MARGIN_RIGHT, //右边距
    STYLE_MARGIN_TOP, //顶边距
    STYLE_MARGIN_BOTTOM, //底边距
    STYLE_ICON_AT, //STYLE_ICON_AT
    STYLE_ACTIVE_ICON, //图标的名称
    STYLE_X_OFFSET, //X方向的偏移，方便实现按下的效果
    STYLE_Y_OFFSET, //Y方向的偏移，方便实现按下的效果
    STYLE_SELECTED_BG_COLOR, //编辑器中选中区域的背景颜色
    STYLE_SELECTED_FG_COLOR, //编辑器中选中区域的前景颜色
    STYLE_SELECTED_TEXT_COLOR, //编辑器中选中区域的文本颜色
    STYLE_ROUND_RADIUS, //圆角半径(仅在WITH_VGCANVAS定义时生效)
    STYLE_ROUND_RADIUS_TOP_LETF, //左上角圆角半径(仅在WITH_VGCANVAS定义时生效)
    STYLE_ROUND_RADIUS_TOP_RIGHT, //右上角圆角半径(仅在WITH_VGCANVAS定义时生效)
    STYLE_ROUND_RADIUS_BOTTOM_LETF, //左下角圆角半径(仅在WITH_VGCANVAS定义时生效)
    STYLE_ROUND_RADIUS_BOTTOM_RIGHT, //右下角圆角半径(仅在WITH_VGCANVAS定义时生效)
};


enum
{    
    STYLE_STATE_NONE = 0,
    STYLE_STATE_NORMAL = (1 << 0), //正常状态
    STYLE_STATE_CHANGED = (1 << 1), //内容被修改的状态
    STYLE_STATE_PRESSED = (1 << 2), //指针按下状态
    STYLE_STATE_OVER = (1 << 3), //指针悬浮状态
    STYLE_STATE_DISABLE = (1 << 4), //禁用状态
    STYLE_STATE_FOCUSED = (1 << 5), //聚焦状态
    STYLE_STATE_CHECKED = (1 << 6), //勾选状态
    STYLE_STATE_UNCHECKED = (1 << 7), //没勾选状态
    STYLE_STATE_EMPTY = (1 << 8), //编辑器无内容状态
    STYLE_STATE_EMPTY_FOCUS = (1 << 9), //编辑器无内容同时聚焦的状态
    STYLE_STATE_ERROR = (1 << 10), //输入错误状态
    STYLE_STATE_SELECTED = (1 << 11), //选中状态
    STYLE_STATE_NORMAL_OF_CHECKED = (1 << 12), //正常状态(选中项)
    STYLE_STATE_PRESSED_OF_CHECKED = (1 << 13), //指针按下状态(选中项)
    STYLE_STATE_OVER_OF_CHECKED = (1 << 14), //指针悬浮状态(选中项)
    STYLE_STATE_DISABLE_OF_CHECKED = (1 << 15), //禁用状态(选中项)
    STYLE_STATE_FOCUSED_OF_CHECKED = (1 << 16), //焦点状态(选中项)
    STYLE_STATE_NORMAL_OF_ACTIV = (1 << 17), //正常状态(当前项)
    STYLE_STATE_PRESSED_OF_ACTIVE = (1 << 18), //指针按下状态(当前项)
    STYLE_STATE_OVER_OF_ACTIVE = (1 << 19), //指针悬浮状态(当前项)
    STYLE_STATE_DISABLE_OF_ACTIVE = (1 << 20), //禁用状态(当前项)
    STYLE_STATE_FOCUSED_OF_ACTIVE = (1 << 21), //焦点状态(当前项)
};

enum {
    STYLE_ICON_LEFT,
    STYLE_ICON_RIGHT,
    STYLE_ICON_TOP,
    STYLE_ICON_BOTTOM,
    STYLE_ICON_CENTER,
};

enum {
    STYLE_DRAW_DEFAULT,
    STYLE_DRAW_SCALE,
    STYLE_DRAW_REPATE,
};

class QStyle
{
public:    
    static void getAlign(int qAlign,int &align_v,int &align_h);

    QString styleSheet();    
    
    void text_color(const QColor &c, int state = STYLE_STATE_NONE);
    void bg_color(const QColor &c, int state = STYLE_STATE_NONE);
    void color(int style, const QColor &c, int state = STYLE_STATE_NONE);
    void bg_image(QString path,int type = STYLE_DRAW_SCALE, int state = STYLE_STATE_NONE);
    void icon(QString path, int type = STYLE_ICON_LEFT, int state = STYLE_STATE_NONE);
    void font_name(QString name, int state = STYLE_STATE_NONE);
    void font_size(int size, int state = STYLE_STATE_NONE);
    void textAlign(int align, int state = STYLE_STATE_NONE);
    void style(int stype_id,const QString &text,int state = STYLE_STATE_NONE);

protected:
    void expandState(QString &signal, int state);

    QString m_style;
};

void style_init();

#endif /*TK_STYLE_H*/
